Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scroll-into-view-if-needed

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-into-view-if-needed

Ponyfill for upcoming Element.scrollIntoView() APIs like scrollMode: if-needed, behavior: smooth and block: center

  • 2.2.31
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6M
decreased by-7.7%
Maintainers
1
Weekly downloads
 
Created

What is scroll-into-view-if-needed?

The scroll-into-view-if-needed npm package is a smooth scroll polyfill for the 'scrollIntoViewIfNeeded' DOM method, which allows elements to be scrolled into the viewport if they are not already visible. It provides a way to scroll an element into view, aligning it according to the specified options only if it is not already in view.

What are scroll-into-view-if-needed's main functionalities?

Basic scrolling into view if needed

This is the simplest use case where you can call the method on an element to ensure it is visible in the viewport.

element.scrollIntoViewIfNeeded();

Custom options for scrolling

This allows you to define custom options for the scrolling behavior, such as the alignment of the scrolled-to element within the viewport.

scrollIntoViewIfNeeded(node, {block: 'nearest', inline: 'nearest'});

Polyfill for unsupported browsers

The package can be used as a polyfill to provide the functionality in browsers that do not support 'scrollIntoViewIfNeeded' natively.

import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
scrollIntoViewIfNeeded(node);

Other packages similar to scroll-into-view-if-needed

Keywords

FAQs

Package last updated on 29 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc